﻿// Version:1
// Author:Sanket Naik
// Date:July-21-2010 
// Comments:
// 
// 
// 

using System.Diagnostics;

namespace ManagedServices.Common.Logger
{
    /// <summary>
    /// The Logger class, which Implements ILogger Interface. This Internally Uses Trace
    /// </summary>
    public class LoggerImpl : ILogger
    {
        #region ILogger Members

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="method"></param>
        /// <param name="message"></param>
        public void WriteInfo(string type, string method, string message)
        {
            string info = "Info";
            Trace.WriteLine(GetLoggableMessage(type, method, message, info), info);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="method"></param>
        /// <param name="message"></param>
        public void WriteDebug(string type, string method, string message)
        {
            string info = "Debug";
            Trace.WriteLine(GetLoggableMessage(type, method, message, info), info);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="method"></param>
        /// <param name="message"></param>
        public void WriteWarning(string type, string method, string message)
        {
            string info = "Warning";
            Trace.WriteLine(GetLoggableMessage(type, method, message, info), info);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="method"></param>
        /// <param name="message"></param>
        public void WriteError(string type, string method, string message)
        {
            string info = "Error";
            Trace.WriteLine(GetLoggableMessage(type, method, message, info), info);
        }

        #endregion

        private string GetLoggableMessage(string type, string method, string message, string category)
        {
            return string.Format("[{0}]-{1} {2} Message:{3}", category, type, method, message);
        }
    }
}